<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Thông tin shop</title>
		<link rel="stylesheet" href="../css/reset.css" type="text/css" />
		<link rel="stylesheet" href="../css/common.css" type="text/css" />
		<link rel="stylesheet" href="../css/seller.css" type="text/css" />
		<script src="../scripts/jquery-1.5.2.min.js"></script>
		<script src="../scripts/common.js"></script>
		<script type="text/javascript">
			var xmlhttp;
	
			function GetXmlHttpObject()
			{
				if (window.XMLHttpRequest)
				{
					// code for IE7+, Firefox, Chrome, Opera, Safari
					return new XMLHttpRequest();
				}
				if (window.ActiveXObject)
				{
					// code for IE6, IE5
					return new ActiveXObject("Microsoft.XMLHTTP");
				}
				return null;
			}
			
			function XemChiTiet(MaHD)
			{
				xmlhttp = GetXmlHttpObject();
				if(xmlhttp == null)
				{
					alert("Browser do not support HTTP REQUEST");
					return;
				}
				var url = "../BUS/xl_HoaDon.php?MaHD=" + MaHD;
				xmlhttp.onreadystatechange=XemChiTiet_Change;
				xmlhttp.open("GET",url,true);
				xmlhttp.send("null");
			}
			
			function XemChiTiet_Change()
			{
				if (xmlhttp.readyState==4)
				{
					document.getElementById("divdetail").innerHTML=xmlhttp.responseText;
				}
			}
		</script>
	</head>
	<body>
		<div id="page">
			<?php
				require("../DAO/DataHelper.php");
				require("../webconfig.php");
				include_once("../DAO/DonHangDTO.php");
				include_once("../DAO/DonHangDAO.php");
				include_once("../DAO/TaiKhoan_DAO.php");
				require("../UserControl/header.php");
				if(isset($_SESSION["Role"]))
				{
					if($_SESSION["Role"] != 0)
					{
						$url = GetUrl("index.php");
						$message = 'Vui lòng đăng nhập đúng quyền trước khi sử dụng các chức năng!';
						echo "<script>javascript:alert('".$message."'); window.location = '".$url."'</script>";
					}
				}
			?>

			<div id="content">
				<div id="shop-banner">
					<img src="../temp/shop-banner.jpg" />
				</div>
				<?php
					require("../UserControl_NguoiBan/MenuDanhMucChucNang.php");
				?>
				<div id="seller-shop-info" class="block layout-2col-col2">
					<div class="title">
					  <h3>Danh sách các đơn hàng </h3>
					</div>
					<div class="content">
 						<table style="width: 666px;" id="gradient-style" summary="Meeting Results">
                            <thead>
                                <tr>
                                <th style="width: 200px;" scope="col">Ngày giờ đặt mua</th>
								<th style="width: 200px;" scope="col">Ngày giao</th>
                                <th width="120" scope="col">Trạng Thái </th>
								<th width="210" scope="col">Tổng tiền</th>
                                <th width="210" scope="col">Xem chi tiết</th>
                                </tr>
                            </thead>
                            
                            <tbody id="tbody">
							<?php
								
								$listhoadon = DonHangDAO::DanhSachCacDonHangCuaKhachHang($_SESSION["UserName"]);
								$i = 0;
								if($listhoadon != null)
									foreach($listhoadon as $hoadon)
									{
									
							?>
                                <tr>
                                    <td style="background: #d1d1d1;"><a style=' font-weight:bold; cursor:pointer'><?php echo $hoadon->dh_ngay_dat ?></a><input id="mahd" type="hidden" value="<?php echo $hoadon->dh_ma ?>" /></td>
                                    <td style="background: #d1d1d1;"><?php echo $hoadon->dh_ngay_giao ?></td>
                                    
                                    <td style='background: #d1d1d1;'>
                                    <lable style='color: purple;'  />
                                    	<?php 
											if($hoadon->dh_tinh_trang == 0) 
												echo "Đang chờ duyệt";
											else
												echo "Đã duyệt xong";
                                    	?>
                                    </lable>
                                    </td>
                                    <td style="background: #d1d1d1;"><lable style='color: red; font-weight:bold'  /><?php echo $hoadon->dh_tong_tien ?></lable></td>
                                    <td style="background: #d1d1d1; text-align:center; cursor:pointer">
                                    	<img src="../images/xem-chi-tiet.png" height="20" width="20" onclick="XemChiTiet(<?php echo $hoadon->dh_ma ?>)"/>
                                    </td>
                                </tr>
                                
                            <?php
								
								}
							?>
                            </tbody>
                            <tfoot>
                                <tr>
                                <td colspan="9">Give background color to the table cells to achieve seamless transition</td>
                                </tr>
                            </tfoot>
                      </table> 
					</div>
                    <div id="divdetail"></div>
				</div>
			</div>
			<?php
				require("../UserControl/footer.php");
			?>
		</div>
	</body>
</html>
